POV-Ray : Newsgroups : povray.advanced-users : Question about scale & translation : Re: Question about scale & translation Server Time
28 Jul 2024 22:19:59 EDT (-0400)
  Re: Question about scale & translation  
From:
Date: 2 Aug 2003 20:21:29
Message: <3f2c5589$1@news.povray.org>
/*

Hi Steve,

here is a scene slightly more flexible than requested by you -- simply
copy this *whole* mail to POV-Ray, set the options

// +SP8 +EP8 -F +D +A0.1

render, look, read the heavily commented code and ask if you have questions!
Many variations are possible: additional rotations (add
    rotate <C_N*180, 0, C_N*360>
after scale of object), gap between objects, mix of different objects, ...


   Sputnik

*/


#declare Number = 30; // Number of objects to be stacked along y-axis
#declare Object = cylinder { 0, y, 1 pigment { color rgb 1 } }
#declare Start = <0, 0, 0>; // arbitrary starting point
#declare Position = Start; // position for object


// loop for Counter = 0, 1, ..., Number-1
#declare Count = 0;
#while (Count<Number)

  // auxiliary variable,  ranging from 0 to 1
  #declare C_N = Count/(Number-1);

  // make next object to be stacked; may depend on Count
  #declare Object = cylinder { 0, y, 1
    // scale the object by an arbitrary amount depending on Count
    // uneven scaling is possible, for example try the following:
    scale <4+3*cos(pi*C_N), 1, 2+cos(5*pi*C_N)>
    // scale 1+Count*0.04 // 1; 1.04; 1.08; 1.12; ...
    pigment { color rgb <1, C_N, 0.3> }
    finish { ambient .4 diffuse .6 }
    }

  // find smallest and largest y of this object and its y-size
  #declare MinY = min_extent(Object).y;
  #declare MaxY = max_extent(Object).y;
  #declare SizeY= MaxY-MinY;

  // put object into scene with it's bottom at Position
  // (first translate the bottom to origin, from there to Position)
  object { Object translate -MinY*y + Position }

  // update the Position for the next object
  #declare Position = Position + SizeY*y;

  // loop
  #declare Count = Count+1;
  #end//while Count


// we all love this, even without reflecting sphere ...
plane { y, 0 pigment { checker scale 10 } }

// light
light_source { <-2, 3, -1>*1000, rgb 1 }

// camera, translated to look at 55% of the height of the stack of objects
camera {
  location <1, 3, -2>*(Position.y-Start.y)/2
  look_at 0
  translate (Start+0.55*(Position-Start))*y
  angle 30
  }


// END


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.